#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> plusOne(vector<int>& digits) {
        vector<int> v1(digits);
        vector<int>::reverse_iterator it = v1.rbegin();
        int add = 1;
        while (add == 1 && it != v1.rend())
        {
            (*it)++;
            if (*it == 10)
            {
                *it = 0;
            }
            else
            {
                --add;
            }
            ++it;
        }
        if (add)
            v1.insert(v1.begin(), 1);

        return v1;
    }
};